package com.jiguang.property.controller;


import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.jiguang.property.annotation.Log;
import com.jiguang.property.dto.BuildInfoDTO;
import com.jiguang.property.dto.UserInfoDTO;
import com.jiguang.property.entity.BuildInfo;
import com.jiguang.property.service.BuildInfoService;
import com.jiguang.property.utils.Result;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author testjava
 * @since 2025-01-24
 */
@RestController
@RequestMapping("/buildInfo")
@CrossOrigin
public class BuildInfoController {
    @Autowired
    private BuildInfoService buildInfoService;

    @ApiOperation(value = "获取楼宇信息列表")
    @PostMapping("listAll")
    public Result listAll() {
        return Result.ok().data("buildInfos",buildInfoService.list(new QueryWrapper<BuildInfo>().eq("is_delete",0)));
    }

    @ApiOperation(value = "获取楼宇信息列表")
    @PostMapping("list")
    @Log(name = "查询楼宇列表")
    public Result list(@RequestBody BuildInfoDTO buildInfoDTO) {
        return buildInfoService.listBuildInfo(buildInfoDTO);
    }

    @ApiOperation(value = "通过ID删除楼宇信息")
    @PostMapping("delete")
    @Log(name = "删除楼宇信息")
    public Result delete(String buildId) {
        return buildInfoService.deleteBuildInfo(buildId);
    }

    @ApiOperation(value = "新增楼宇信息")
    @PostMapping("saveOrUpdate")
    @Log(name = "操作楼宇信息")
    public Result updateOrAdd(@RequestBody BuildInfoDTO buildInfoDTO) {
        return buildInfoService.updateOrAddBuildInfo(buildInfoDTO);
    }
}

